package com.fwtai.web;

import com.fwtai.bean.PageFormData;
import com.fwtai.datasource.DaoHandle;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

/**
 * 产品分类访问数据库
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2023-08-23 14:49:22
 * @QQ号码 444141300
 * @Email service@fwtai.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@Repository
public class GoodsCategoryDao{

  private final DaoHandle dao;

  public GoodsCategoryDao(final DaoHandle dao){
    this.dao = dao;
  }

  public int add(final PageFormData formData){
    return dao.execute("goods_category.add",formData);
  }

  public int edit(final PageFormData formData){
    return dao.execute("goods_category.edit",formData);
  }

  public Long queryExistById(final long kid){
    return dao.queryForLong("goods_category.queryExistById",kid);
  }

  public HashMap<String,Object> queryById(final long kid){
    return dao.queryForHashMap("goods_category.queryById",kid);
  }

  public int delById(final long kid){
    return dao.execute("goods_category.delById",kid);
  }

  //查询数据是否已被别的关联表使用,list不允许为空,删除单个时使用 XxxDao.queryIsUsed(new long[]{user_id});批量删除时使用 XxxDao.queryIsUsed(list);
  public List<Long> queryIsUsed(final long kids){
    return dao.queryListEntity("goods_category.queryIsUsed",kids);
  }

  public List<HashMap<String,Object>> getListData(final PageFormData formData){
    return dao.queryForListHashMap("goods_category.listData",formData);
  }

  public Integer getListTotal(final PageFormData formData){
    return dao.queryForInteger("goods_category.listTotal",formData);
  }
}